home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Linux Cubed Series 8: LINUX Games
/
Linux Cubed Series 8 - LINUX Games.iso
/
games
/
x11
/
strategy
/
connx-1.001
/
connx-1~
/
connect.h
< prev
next >
Wrap
C/C++ Source or Header
|
1995-02-11
|
3KB
|
140 lines
/*
* message types and structures for connx game
*/
#ifndef CONN_H
#define CONN_H
#include "commun.h"
/* maximum player name size */
#define NAME_SIZE 10
/* maximum number of players */
#define MAX_PLAYERS MAX_CONN
/* maximum number of rows */
#define MAX_ROW 50
/* maximum number of columns */
#define MAX_COL 50
/* maximum number of pieced to connect to win */
#define MAX_CONNECT 50
/* defaults number of rows */
#define DEF_ROW 10
/* default number of columns */
#define DEF_COL 10
/* default number of pieces to connect to win */
#define DEF_CONNECT 4
/* game types */
/* gravity - pieces fall to bottom */
/* nogravity - pieces go in whatever coord you pick */
#define GRAVITY 0
#define NOGRAVITY 1
/* default game type */
#define DEF_GAME GRAVITY
/*default timeout = no timeout */
#define DEF_TIMEOUT 0
typedef struct coord
{
int row;
int column;
}
coord;
typedef int board[MAX_ROW][MAX_COL];
/*****************************************************************************/
/* message types */
enum
{
NEW_PLAYER, OTHERS_MOVE, YOUR_MOVE, GAME_START,
GAME_END, REQUEST, RESPONSE, MY_MOVE, WHOSE_MOVE, CANCEL_MOVE
};
/* Note: YOUR_MOVE has no message data associated with it.
It is sent to client whose turn it is. */
/* maximum message size */
#define MAX_DATA sizeof(game_start)
/****MESSAGES*****************************************************************/
/* new player sends this message to server*/
typedef struct new_player_message
{
char name[NAME_SIZE];
}
new_player;
/* server sends this message to say whose move it is */
typedef struct whose_move_message
{
int player;
}
whose_move;
/* client sends this message to server to indicate move.
* The message is returned by server with rc indicating if
* move is successful or not */
#define FORFEIT -1
typedef struct my_move_message
{
int rc;
coord move;
}
my_move;
/* server sends this message to clients to indicates
other players' moves */
typedef struct others_move_message
{
int player_number;
coord move;
}
others_move;
/* message sent by server at beginning of game */
typedef struct game_start_message
{
int game_type;
int num_players;
int num_rows;
int num_columns;
int num_connect;
int your_number;
int timeout;
char players[MAX_PLAYERS][NAME_SIZE];
int team_numbers[MAX_PLAYERS];
}
game_start;
#define TIE_GAME -1
#define CANCEL_GAME -2
/* message sent by server at end of game */
typedef struct game_end_message
{
int winner;
coord connect[2];
}
game_end;
#endif